package com.smh.a02loginAndRegister;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) throws IOException {

        File file = new File("day28-code\\file\\user\\userinfo.txt");

        BufferedReader br = new BufferedReader(new FileReader(file));

        HashMap<String, String> hm = new HashMap<>();

        String line;
        while ((line = br.readLine()) != null) {
            String[] split = line.split("(&|=)");
            hm.put(split[1], split[3]);
        }

        System.out.println(hm);

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名");
        String name = scanner.nextLine();
        System.out.println("请输入密码");
        String password = scanner.nextLine();

        if (hm.containsKey(name)) {
            if (hm.get(name).equals(password)) {
                System.out.println("登陆成功");
            } else {
                System.out.println("登陆失败");
            }
        } else {
            System.out.println("登陆失败");
        }


    }
}
